<?php 
	$hfbsets = getHFBSetList(); 
	$borders = getBordersList();
	$types = getThemeTypes();
	require('components/common/toolbox.php'); 
?>
<input type="hidden" name="action" value="editor" />
<input type="hidden" name="item" value="<?php echo $item['id']; ?>" />
<fieldset>
	<dl>
		<dt>Main Settings</dt>
		<dd><input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" class="buttons">
		</dd>
	</dl>
	<dl>
		<dt>Title:</dt>
		<dd>
			<input name="title" type="text" value="<?php echo $item['title']; ?>" style="width:50%">
			&nbsp;<?php echo $error['title']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Type:</dt>
		<dd>
			<?php 
			if($types)
			{
				foreach($types as $type)
				{
					if ($type['id'] == $item['theme_type'])
					{ 
						$theme_type = $type;
						echo '<img id="theme_type_img" style="cursor:pointer;" onmouseover="swapSource(this, \'_\');" onmouseout="swapSourceBack(this, \'_\');" onclick="swapDisplay(\'types_dl\');" src="../images/system/layouts/'.$type['type'].'.gif" alt="'.$type['type'].'" />'; 
					}
				}
			}
			?>
			<input id="theme_type" type="hidden" name="theme_type" value="<?php echo $item['theme_type']; ?>" />
			&nbsp;<?php echo $error['theme_type']; ?>
		</dd>
	</dl>
	<dl id="types_dl" style="display:none">
		<dt>Select new type:</dt>
		<dd>
			<table border="0" cellpadding="0" cellspacing="0">
				<?php 
					$k = 1;
					for($i=0; $i<4; $i++)
					{
						echo'<tr>';
						for($j=1; $j<5; $j++)
						{
							echo'<td style="padding-right:4px; padding-bottom:4px;">';
							echo '<img onclick="document.getElementById(\'theme_type\').value = '.$k.'; swapSourceBack(this, \'_\'); document.getElementById(\'theme_type_img\').src = this.src; swapSource(this, \'_\'); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, \'_\');" onmouseout="swapSourceBack(this, \'_\'); " src="../images/system/layouts/'.$i.'-'.$j.'.gif" alt="0-1" />';
							echo'</td>';
							$k++;
							
						}
						echo'</tr>';
					}
				?>
				
			</table>
		</dd>
	</dl>
	<dl>
		<dt>Layout Width: <strong><?php if($item['fixed_width'] == 0) {echo "Liquid";} else {echo "Fixed";} ?></strong></dt>
		<dd>
			<img onclick="setChecked('f-0', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/f-0.gif" />
			<input id="f-0" type="radio" name="fixed_width" onChange="submit();" value="0" <?php if($item['fixed_width'] == 0) {echo "checked";} ?> />
			<img onclick="setChecked('f-1', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/f-1.gif" />
			<input id="f-1" type="radio" name="fixed_width" onChange="submit();" value="1" <?php if($item['fixed_width'] == 1) {echo "checked";} ?> />
			&nbsp;<?php echo $error['fixed_width']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Horizontal Position: <strong>
			<?php if($item['horisontal_pos'] == 0) {echo "Left";} ?>
			<?php if($item['horisontal_pos'] == 1) {echo "Center";} ?>
			<?php if($item['horisontal_pos'] == 2) {echo "Right";} ?></strong>
		</dt>
		<dd>
			<img onclick="setChecked('a-0', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/a-0.gif" alt="left" />
			<input id="a-0" type="radio" name="horisontal_pos" onChange="submit();" value="0" <?php if($item['horisontal_pos'] == 0) {echo "checked";} ?> />
			<img onclick="setChecked('a-1', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/a-1.gif" alt="center" />
			<input id="a-1" type="radio" name="horisontal_pos" onChange="submit();" value="1" <?php if($item['horisontal_pos'] == 1) {echo "checked";} ?> />
			<img onclick="setChecked('a-2', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/a-2.gif" alt="right" />
			<input id="a-2" type="radio" name="horisontal_pos" onChange="submit();" value="2" <?php if($item['horisontal_pos'] == 2) {echo "checked";} ?> />
			&nbsp;<?php echo $error['horisontal_pos']; ?>
		</dd>
	</dl>
    <dl>
		<dt>Grid System:</dt>
		<dd>
			<select name="GridSystem" onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					for($i=1; $i<100; $i++)
					{
						if ($i == $item['GridSystem'])
						{ echo '<option value="'.$i.'" selected="selected">'.$i.'</option>'; }
						else
						{ echo '<option value="'.$i.'">'.$i.'</option>'; }
					}
				?>
			</select>
			&nbsp;<?php echo $error['border']; ?>
		</dd>
	</dl><div class="clear" style="clear:both;"></div>
	<dl>
		<dt>Bootstrap:</dt>
		<dd>
			<select name="Bootstrap" onchange="submit();" style="width:50%;">
				<option value="0" <?php if($item['Bootstrap'] == 0) { echo 'selected'; } ?>>No</option>
				<option value="1" <?php if($item['Bootstrap'] == 1) { echo 'selected'; } ?>>Yes</option>
			</select>
		</dd>
	</dl><div class="clear" style="clear:both;"></div>
	<dl>
		<dt>Site Border:</dt>
		<dd>
			<select name="border_site" onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['border_site'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['border']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Content Border:</dt>
		<dd>
			<select name="border_content" onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['border_content'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['border_content']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Default Component HFB Set:</dt>
		<dd>
			<select name="hfb_com_set" style="width:50%;" onChange="submit();"  >
				<option value="0">None</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] == $item['hfb_com_set'])
						{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
						else
						{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['hfb_com_set']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Default Module HFB Set:</dt>
		<dd>
			<select name="hfb_set" style="width:50%;" onChange="submit();" >
				<option value="0">None</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] == $item['hfb_set'])
						{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
						else
						{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['hfb_com_set']; ?>
		</dd>
	</dl>
	<?php 
	if($theme_type['header'] == 1): ?>
	<dl>
		<dt>Header Layout Width: <strong><?php if($item['header_fixed'] == 0) {echo "Liquid";} else {echo "Fixed";} ?></strong></dt>
		<dd>
			<img onclick="setChecked('fh-0', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/fh-0.gif" />
			<input id="fh-0" type="radio" name="header_fixed" onChange="submit();" value="0" <?php if($item['header_fixed'] == 0) {echo "checked";} ?> />
			<img onclick="setChecked('fh-1', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/fh-1.gif" />
			<input id="fh-1" type="radio" name="header_fixed" onChange="submit();" value="1" <?php if($item['header_fixed'] == 1) {echo "checked";} ?> />
			&nbsp;<?php echo $error['header_fixed']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Header Border Type:</dt>
		<dd>
			<select name="header_border" onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['header_border'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['header_border']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Header HFB Set:</dt>
		<dd>
			<select name="header_hfb" style="width:50%;" onChange="submit();"  >
				<option value="0">Theme Default</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] != $item['hfb_set'])
						{
							if ($hfbset['id'] == $item['header_hfb'])
							{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
							else
							{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
						}
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['hfb_com_set']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Header Content:</dt>
		<dd>
			<select name="header_content" onChange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					$content = getContentTemplates($item['site_id'], 1);
					if($content)
					{
						foreach($content as $con)
						{
							if ($con['id'] == $item['header_content'])
							{ echo '<option value="'.$con['id'].'" selected="selected">'.$con['title'].'</option>'; }
							else
							{ echo '<option value="'.$con['id'].'">'.$con['title'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['header_content']; ?>
		</dd>
	</dl>
	<?php endif; ?>
	<?php if($theme_type['footer'] == 1): ?>
	<dl>
		<dt>Footer Layout Width: <strong><?php if($item['footer_fixed'] == 0) {echo "Liquid";} else {echo "Fixed";} ?></strong></dt>
		<dd>
			<img onclick="setChecked('ff-0', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/ff-0.gif" />
			<input id="ff-0" type="radio" name="footer_fixed" onChange="submit();" value="0" <?php if($item['footer_fixed'] == 0) {echo "checked";} ?> />
			<img onclick="setChecked('ff-1', true); edit_form.submit();" style="cursor:pointer;" onmouseover="swapSource(this, '_');" onmouseout="swapSourceBack(this, '_');" src="../images/system/layouts/ff-1.gif" />
			<input id="ff-1" type="radio" name="footer_fixed" onChange="submit();" value="1" <?php if($item['footer_fixed'] == 1) {echo "checked";} ?> />
			&nbsp;<?php echo $error['footer_fixed']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Footer Border Type:</dt>
		<dd>
			<select name="footer_border" onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['footer_border'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['footer_border']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Footer HFB Set:</dt>
		<dd>
			<select name="footer_hfb" style="width:50%;" onChange="submit();"  >
				<option value="0">Theme Default</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] != $item['hfb_set'])
						{
							if ($hfbset['id'] == $item['footer_hfb'])
							{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
							else
							{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
						}
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['hfb_com_set']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Footer Content:</dt>
		<dd>
			<select name="footer_content" onChange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					$content = getContentTemplates($item['site_id'], 2);
					if($content)
					{
						foreach($content as $con)
						{
							if ($con['id'] == $item['footer_content'])
							{ echo '<option value="'.$con['id'].'" selected="selected">'.$con['title'].'</option>'; }
							else
							{ echo '<option value="'.$con['id'].'">'.$con['title'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['footer_content']; ?>
		</dd>
	</dl>
	<?php endif; ?>
	<?php if($theme_type['col_left'] == 1): ?>
	<dl>
		<dt>Column Left Border:</dt>
		<dd>
			<select name="col_left_border"  onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['col_left_border'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['col_left_border']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Column Left HFB Set:</dt>
		<dd>
			<select name="col_left_hfb" style="width:50%;" onChange="submit();"  >
				<option value="0">Theme Default</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] != $item['hfb_set'])
						{
							if ($hfbset['id'] == $item['col_left_hfb'])
							{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
							else
							{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
						}
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['col_left_hfb']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Column Left Template:</dt>
		<dd>
			<select name="col_left_content"  onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					$content = getContentTemplates($item['site_id'], 3);
					if($content)
					{
						foreach($content as $con)
						{
							if ($con['id'] == $item['col_left_content'])
							{ echo '<option value="'.$con['id'].'" selected="selected">'.$con['title'].'</option>'; }
							else
							{ echo '<option value="'.$con['id'].'">'.$con['title'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['col_left_content']; ?>
		</dd>
	</dl>
	<?php endif; ?>
	<?php if($theme_type['col_right'] == 1): ?>
	<dl>
		<dt>Column Right Border Type:</dt>
		<dd>
			<select name="col_right_border"  onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					if($borders)
					{
						foreach($borders as $border)
						{
							if ($border['id'] == $item['col_right_border'])
							{ echo '<option value="'.$border['id'].'" selected="selected">'.$border['name'].'</option>'; }
							else
							{ echo '<option value="'.$border['id'].'">'.$border['name'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['col_right_border']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Column Right HFB Set:</dt>
		<dd>
			<select name="col_right_hfb" style="width:50%;" onChange="submit();"  >
				<option value="0">Theme Default</option>
				<?php 
				if($hfbsets)
				{
					foreach($hfbsets as $hfbset)
					{
						if ($hfbset['id'] != $item['hfb_set'])
						{
							if ($hfbset['id'] == $item['col_right_hfb'])
							{ echo '<option value="'.$hfbset['id'].'" selected="selected">'.$hfbset['name'].'</option>'; }
							else
							{ echo '<option value="'.$hfbset['id'].'">'.$hfbset['name'].'</option>'; }
						}
					}
				}
				?>
			</select>
			&nbsp;<?php echo $error['col_left_hfb']; ?>
		</dd>
	</dl>
	<dl>
		<dt>Column Right Template:</dt>
		<dd>
			<select name="col_right_content"  onchange="submit();" style="width:50%;">
				<option value="0" selected>None</option>
				<?php 
					$content = getContentTemplates($item['site_id'], 3);
					if($content)
					{
						foreach($content as $con)
						{
							if ($con['id'] == $item['col_right_content'])
							{ echo '<option value="'.$con['id'].'" selected="selected">'.$con['title'].'</option>'; }
							else
							{ echo '<option value="'.$con['id'].'">'.$con['title'].'</option>'; }
						}
					}
				?>
			</select>
			&nbsp;<?php echo $error['col_right_content']; ?>
		</dd>
	</dl>
	<?php endif; ?>
</fieldset>
	<input type="hidden" name="header" value="<?php echo $theme_type['header']; ?>"  />
	<input type="hidden" name="footer" value="<?php echo $theme_type['footer']; ?>"  />
	<input type="hidden" name="col_left" value="<?php echo $theme_type['col_left']; ?>"  />
	<input type="hidden" name="col_right" value="<?php echo $theme_type['col_right']; ?>"  />

